using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class NXHOADONInfo
    {
		#region Local Variable
		public enum Field
		{
			NO,
			LINE,
			SOBT,
			LOAICT,
			NGAYGD,
			MAHANG,
			DVTINH,
			SOLUONG,
			GIAVON,
			GIABAN,
			SOTIEN,
			TIENVON
		}
		private Int64 _NO;
		private Int32 _LINE;
		private String _SOBT;
		private String _LOAICT;
		private DateTime _NGAYGD;
		private String _MAHANG;
		private String _DVTINH;
		private Double _SOLUONG;
		private Double _GIAVON;
		private Double _GIABAN;
		private Double _SOTIEN;
		private Double _TIENVON;
		
		public Int64 NO{	get{ return _NO;} set{_NO = value;} }
		public Int32 LINE{	get{ return _LINE;} set{_LINE = value;} }
		public String SOBT{	get{ return _SOBT;} set{_SOBT = value;} }
		public String LOAICT{	get{ return _LOAICT;} set{_LOAICT = value;} }
		public DateTime NGAYGD{	get{ return _NGAYGD;} set{_NGAYGD = value;} }
		public String MAHANG{	get{ return _MAHANG;} set{_MAHANG = value;} }
		public String DVTINH{	get{ return _DVTINH;} set{_DVTINH = value;} }
		public Double SOLUONG{	get{ return _SOLUONG;} set{_SOLUONG = value;} }
		public Double GIAVON{	get{ return _GIAVON;} set{_GIAVON = value;} }
		public Double GIABAN{	get{ return _GIABAN;} set{_GIABAN = value;} }
		public Double SOTIEN{	get{ return _SOTIEN;} set{_SOTIEN = value;} }
		public Double TIENVON{	get{ return _TIENVON;} set{_TIENVON = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public NXHOADONInfo()
		{
			_NO = 0;
			_LINE = 0;
			_SOBT = "";
			_LOAICT = "";
			_NGAYGD = DateTime.Now;
			_MAHANG = "";
			_DVTINH = "";
			_SOLUONG = 0;
			_GIAVON = 0;
			_GIABAN = 0;
			_SOTIEN = 0;
			_TIENVON = 0;
		}
		public NXHOADONInfo(
		Int64 NO,
		Int32 LINE,
		String SOBT,
		String LOAICT,
		DateTime NGAYGD,
		String MAHANG,
		String DVTINH,
		Double SOLUONG,
		Double GIAVON,
		Double GIABAN,
		Double SOTIEN,
		Double TIENVON
		)
		{
			_NO = NO;
			_LINE = LINE;
			_SOBT = SOBT;
			_LOAICT = LOAICT;
			_NGAYGD = NGAYGD;
			_MAHANG = MAHANG;
			_DVTINH = DVTINH;
			_SOLUONG = SOLUONG;
			_GIAVON = GIAVON;
			_GIABAN = GIABAN;
			_SOTIEN = SOTIEN;
			_TIENVON = TIENVON;
		}
		public NXHOADONInfo(DataRow dr)
		{
			if (dr != null)
			{
				_NO = dr[Field.NO.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.NO.ToString()]);
				_LINE = dr[Field.LINE.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.LINE.ToString()]);
				_SOBT = dr[Field.SOBT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SOBT.ToString()]);
				_LOAICT = dr[Field.LOAICT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.LOAICT.ToString()]);
				_NGAYGD = dr[Field.NGAYGD.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.NGAYGD.ToString()]);
				_MAHANG = dr[Field.MAHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MAHANG.ToString()]);
				_DVTINH = dr[Field.DVTINH.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DVTINH.ToString()]);
				_SOLUONG = dr[Field.SOLUONG.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOLUONG.ToString()]);
				_GIAVON = dr[Field.GIAVON.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIAVON.ToString()]);
				_GIABAN = dr[Field.GIABAN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIABAN.ToString()]);
				_SOTIEN = dr[Field.SOTIEN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOTIEN.ToString()]);
				_TIENVON = dr[Field.TIENVON.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.TIENVON.ToString()]);
			}
		}
		public NXHOADONInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_NO = dr[Field.NO.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.NO.ToString()]);
				_LINE = dr[Field.LINE.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.LINE.ToString()]);
				_SOBT = dr[Field.SOBT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SOBT.ToString()]);
				_LOAICT = dr[Field.LOAICT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.LOAICT.ToString()]);
				_NGAYGD = dr[Field.NGAYGD.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.NGAYGD.ToString()]);
				_MAHANG = dr[Field.MAHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MAHANG.ToString()]);
				_DVTINH = dr[Field.DVTINH.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DVTINH.ToString()]);
				_SOLUONG = dr[Field.SOLUONG.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOLUONG.ToString()]);
				_GIAVON = dr[Field.GIAVON.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIAVON.ToString()]);
				_GIABAN = dr[Field.GIABAN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIABAN.ToString()]);
				_SOTIEN = dr[Field.SOTIEN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOTIEN.ToString()]);
				_TIENVON = dr[Field.TIENVON.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.TIENVON.ToString()]);
			}
		}
		public NXHOADONInfo(NXHOADONInfo objEntr)
		{			
			_NO = objEntr.NO;			
			_LINE = objEntr.LINE;			
			_SOBT = objEntr.SOBT;			
			_LOAICT = objEntr.LOAICT;			
			_NGAYGD = objEntr.NGAYGD;			
			_MAHANG = objEntr.MAHANG;			
			_DVTINH = objEntr.DVTINH;			
			_SOLUONG = objEntr.SOLUONG;			
			_GIAVON = objEntr.GIAVON;			
			_GIABAN = objEntr.GIABAN;			
			_SOTIEN = objEntr.SOTIEN;			
			_TIENVON = objEntr.TIENVON;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("NXHOADON");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.NO.ToString(), typeof(Int64)),
				new DataColumn(Field.LINE.ToString(), typeof(Int32)),
				new DataColumn(Field.SOBT.ToString(), typeof(String)),
				new DataColumn(Field.LOAICT.ToString(), typeof(String)),
				new DataColumn(Field.NGAYGD.ToString(), typeof(DateTime)),
				new DataColumn(Field.MAHANG.ToString(), typeof(String)),
				new DataColumn(Field.DVTINH.ToString(), typeof(String)),
				new DataColumn(Field.SOLUONG.ToString(), typeof(Double)),
				new DataColumn(Field.GIAVON.ToString(), typeof(Double)),
				new DataColumn(Field.GIABAN.ToString(), typeof(Double)),
				new DataColumn(Field.SOTIEN.ToString(), typeof(Double)),
				new DataColumn(Field.TIENVON.ToString(), typeof(Double))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.NO.ToString()] = _NO;
			row[Field.LINE.ToString()] = _LINE;
			row[Field.SOBT.ToString()] = _SOBT;
			row[Field.LOAICT.ToString()] = _LOAICT;
			row[Field.NGAYGD.ToString()] = _NGAYGD;
			row[Field.MAHANG.ToString()] = _MAHANG;
			row[Field.DVTINH.ToString()] = _DVTINH;
			row[Field.SOLUONG.ToString()] = _SOLUONG;
			row[Field.GIAVON.ToString()] = _GIAVON;
			row[Field.GIABAN.ToString()] = _GIABAN;
			row[Field.SOTIEN.ToString()] = _SOTIEN;
			row[Field.TIENVON.ToString()] = _TIENVON;
			return row;
		}
        #endregion InitTable
    }
}
